﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Playables.FrameData
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine.Playables
{
  /// <summary>
  ///   <para>This structure contains the frame information a Playable receives in Playable.PrepareFrame.</para>
  /// </summary>
  public struct FrameData
  {
    internal ulong m_FrameID;
    internal double m_DeltaTime;
    internal float m_Weight;
    internal float m_EffectiveWeight;
    internal double m_EffectiveParentDelay;
    internal float m_EffectiveParentSpeed;
    internal float m_EffectiveSpeed;
    internal FrameData.Flags m_Flags;
    internal PlayableOutput m_Output;

    private bool HasFlags(FrameData.Flags flag) => (this.m_Flags & flag) == flag;

    /// <summary>
    ///   <para>The current frame identifier.</para>
    /// </summary>
    public ulong frameId => this.m_FrameID;

    /// <summary>
    ///   <para>Time difference between this frame and the preceding frame.</para>
    /// </summary>
    public float deltaTime => (float) this.m_DeltaTime;

    /// <summary>
    ///   <para>The weight of the current Playable.</para>
    /// </summary>
    public float weight => this.m_Weight;

    /// <summary>
    ///   <para>The accumulated weight of the Playable during the PlayableGraph traversal.</para>
    /// </summary>
    public float effectiveWeight => this.m_EffectiveWeight;

    /// <summary>
    ///   <para>The accumulated delay of the parent Playable during the PlayableGraph traversal.</para>
    /// </summary>
    [Obsolete("effectiveParentDelay is obsolete; use a custom ScriptPlayable to implement this feature", false)]
    public double effectiveParentDelay => this.m_EffectiveParentDelay;

    /// <summary>
    ///   <para>The accumulated speed of the parent Playable during the PlayableGraph traversal.</para>
    /// </summary>
    public float effectiveParentSpeed => this.m_EffectiveParentSpeed;

    /// <summary>
    ///   <para>The accumulated speed of the Playable during the PlayableGraph traversal.</para>
    /// </summary>
    public float effectiveSpeed => this.m_EffectiveSpeed;

    /// <summary>
    ///   <para>Indicates the type of evaluation that caused PlayableGraph.PrepareFrame to be called.</para>
    /// </summary>
    public FrameData.EvaluationType evaluationType
    {
      get
      {
        return this.HasFlags(FrameData.Flags.Evaluate) ? FrameData.EvaluationType.Evaluate : FrameData.EvaluationType.Playback;
      }
    }

    /// <summary>
    ///   <para>Indicates that the local time was explicitly set.</para>
    /// </summary>
    public bool seekOccurred => this.HasFlags(FrameData.Flags.SeekOccured);

    /// <summary>
    ///   <para>Indicates the local time wrapped because it has reached the duration and the extrapolation mode is set to Loop.</para>
    /// </summary>
    public bool timeLooped => this.HasFlags(FrameData.Flags.Loop);

    /// <summary>
    ///   <para>Indicates the local time did not advance because it has reached the duration and the extrapolation mode is set to Hold.</para>
    /// </summary>
    public bool timeHeld => this.HasFlags(FrameData.Flags.Hold);

    /// <summary>
    ///   <para>The PlayableOutput that initiated this graph traversal.</para>
    /// </summary>
    public PlayableOutput output => this.m_Output;

    /// <summary>
    ///   <para>The accumulated play state of this playable.</para>
    /// </summary>
    public PlayState effectivePlayState
    {
      get
      {
        if (this.HasFlags(FrameData.Flags.EffectivePlayStateDelayed))
          return PlayState.Delayed;
        return this.HasFlags(FrameData.Flags.EffectivePlayStatePlaying) ? PlayState.Playing : PlayState.Paused;
      }
    }

    [System.Flags]
    internal enum Flags
    {
      Evaluate = 1,
      SeekOccured = 2,
      Loop = 4,
      Hold = 8,
      EffectivePlayStateDelayed = 16, // 0x00000010
      EffectivePlayStatePlaying = 32, // 0x00000020
    }

    /// <summary>
    ///   <para>Describes the cause for the evaluation of a PlayableGraph.</para>
    /// </summary>
    public enum EvaluationType
    {
      /// <summary>
      ///   <para>Indicates the graph was updated due to a call to PlayableGraph.Evaluate.</para>
      /// </summary>
      Evaluate,
      /// <summary>
      ///   <para>Indicates the graph was called by the runtime during normal playback due to PlayableGraph.Play being called.</para>
      /// </summary>
      Playback,
    }
  }
}
